import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router)

export default new Router({
  mode:'hash',
  routes: [
    {path:'/',redirect:'/login'},
    {path:'/404',component:()=>import('@/views/error/404.vue'),name:'404',desc:'404未找到'},
    {path:'/login',component:()=>import('@/views/login.vue'),name:'login',desc:'登录',meta:{allowBack:false}},
    {path:'/adminlogin',component:()=>import('@/views/adminlogin.vue'),name:'adminlogin',desc:'登录',meta:{allowBack:false}},
    {path:'/userRegister',component:()=>import('@/views/userRegister.vue'),name:'userRegister',desc:'注册',meta:{allowBack:false}},
    {
      path:'/DigitU',
      component:()=>import('@/views/layout/index.vue'),
      name:'layout',
      redirect:{name:'home'},
      desc:'上左右整体布局',
      children:[
        {path:'/home',component:()=>import('@/views/home/home.vue'),name:'home',desc:'首页'},
        //系统管理员
        {path:'/system/universityAndSchool',component:()=>import('@/views/system/universityAndSchool.vue'),name:'universityAndSchool',desc:'院校管理',meta:{isTab:true}},
        {path:'/system/paramSetting',component:()=>import('@/views/system/paramSetting.vue'),name:'paramSetting',desc:'系统参数设置',meta:{isTab:true}},
        {path:'/system/feedback',component:()=>import('@/views/system/feedback.vue'),name:'feedback',desc:'系统管理员查看反馈信息',meta:{isTab:true}},
        {path:'/permission/resourceManage',component:()=>import('@/views/permission/resourceManage.vue'),name:'resourceManage',desc:'资源管理菜单',meta:{isTab:true}},
        {path:'/permission/roleManage',component:()=>import('@/views/permission/roleManage.vue'),name:'roleManage',desc:'角色管理菜单',meta:{isTab:true}},
        {path:'/permission/rolePermission',component:()=>import('@/views/permission/rolePermission.vue'),name:'rolePermission',desc:'角色授权菜单',meta:{isTab:true}},
        {path:'/permission/userPermission',component:()=>import('@/views/permission/userPermission.vue'),name:'userPermission',desc:'用户授权菜单',meta:{isTab:true}},
        //学院管理员
        {path:'/schoolAdmin/schoolAdminStudent',component:()=>import('@/views/schoolAdmin/schoolAdminStudent.vue'),name:'schoolAdminStudent',desc:'学生基础数据',meta:{isTab:true}},
        {path:'/schoolAdmin/schoolAdminTeacher',component:()=>import('@/views/schoolAdmin/schoolAdminTeacher.vue'),name:'schoolAdminTeacher',desc:'教师基础数据',meta:{isTab:true}},
        {path:'/schoolAdmin/administration',component:()=>import('@/views/schoolAdmin/administration.vue'),name:'administration',desc:'行政管理员账号管理',meta:{isTab:true}},
        {path:'/schoolAdmin/positionType',component:()=>import('@/views/schoolAdmin/positionType.vue'),name:'positionType',desc:'岗位基础信息维护',meta:{isTab:true}},
        {path:'/schoolAdmin/schoolAdminUserPermission',component:()=>import('@/views/schoolAdmin/schoolAdminUserPermission.vue'),name:'schoolAdminUserPermission',desc:'用户授权',meta:{isTab:true}},
        {path:'/schoolAdmin/departmentMajorClass',component:()=>import('@/views/schoolAdmin/departmentMajorClass.vue'),name:'departmentMajorClass',desc:'学院管理员对系部科室的基础数据维护',meta:{isTab:true}},
        //行政管理员
        {path:'/admin/student',component:()=>import('@/views/admin/student.vue'),name:'student',desc:'学生管理',meta:{isTab:true}},
        {path:'/admin/teacher',component:()=>import('@/views/admin/teacher.vue'),name:'teacher',desc:'教师管理',meta:{isTab:true}},
        {path:'/admin/employmentinfo',component:()=>import('@/views/admin/employmentinfo.vue'),name:'employmentinfo',desc:'行政端学生就业管理',meta:{isTab:true}},
        {path:'/admin/interninfo',component:()=>import('@/views/admin/interninfo.vue'),name:'interninfo',desc:'行政端实习管理',meta:{isTab:true}},
        {path:'/admin/orgList',component:()=>import('@/views/admin/orgList.vue'),name:'orgList',desc:'行政端对用人单位的管理',meta:{isTab:true}},
        {path:'/admin/message',component:()=>import('@/views/admin/message.vue'),name:'message',desc:'行政端通知管理',meta:{isTab:true}},
        {path:'/admin/recruitinfo',component:()=>import('@/views/admin/recruitinfo.vue'),name:'recruitinfo',desc:'行政端的招聘',meta:{isTab:true}},
        //企业端
        {path:'/enterprise/company',component:()=>import('@/views/enterprise/company.vue'),name:'company',desc:'企业端单位信息',meta:{isTab:true}},
        {path:'/enterprise/enterpriserecruitInfos',component:()=>import('@/views/enterprise/enterpriserecruitInfos.vue'),name:'enterpriserecruitInfos',desc:'企业招聘',meta:{isTab:true}},
        {path:'/enterprise/enterprisejobApply',component:()=>import('@/views/enterprise/enterprisejobApply.vue'),name:'enterprisejobApply',desc:'企业端应聘',meta:{isTab:true}},
        {path:'/enterprise/interself',component:()=>import('@/views/enterprise/interself.vue'),name:'interself',desc:'企业端搜人才',meta:{isTab:true}},
        //教师端
        {path:'/teacher/teacheremployingUnits',component:()=>import('@/views/teacher/teacheremployingUnits.vue'),name:'teacheremployingUnits',desc:'教师端用人单位',meta:{isTab:true}},
        {path:'/teacher/DairyCheck',component:()=>import('@/views/teacher/DairyCheck.vue'),name:'DairyCheck',desc:'教师端日志评价',meta:{isTab:true}},
        {path:'/teacher/internLists',component:()=>import('@/views/teacher/internLists.vue'),name:'internLists',desc:'教师端获取所指导的学生列表',meta:{isTab:true}},
        {path:'/teacher/teacherrecruitInfos',component:()=>import('@/views/teacher/teacherrecruitInfos.vue'),name:'teacherrecruitInfos',desc:'教师端的招聘',meta:{isTab:true}},
        //学生端
        {path:'/student/CV',component:()=>import('@/views/student/CV.vue'),name:'CV',desc:'学生个人简历',meta:{isTab:true}},
        {path:'/student/Employment',component:()=>import('@/views/student/Employment.vue'),name:'Employment',desc:'学生个人的就业情况',meta:{isTab:true}},
        {path:'/student/introduce',component:()=>import('@/views/student/introduce.vue'),name:'introduce',desc:'学生的自我介绍',meta:{isTab:true}},
        {path:'/student/practiceDiary1',component:()=>import('@/views/student/practiceDiary1.vue'),name:'practiceDiary1',desc:'学生实习日志',meta:{isTab:true}},
        {path:'/student/schoolNotice',component:()=>import('@/views/student/schoolNotice.vue'),name:'schoolNotice',desc:'',meta:{isTab:true}},
        {path:'/student/show-personinfo',component:()=>import('@/views/student/show-personinfo.vue'),name:'show-personinfo',desc:'学生个人信息',meta:{isTab:true}},
        {path:'/student/studentemployingUnits',component:()=>import('@/views/student/studentemployingUnits.vue'),name:'studentemployingUnits',desc:'学生用人单位',meta:{isTab:true}},
        {path:'/student/studentinternInfo',component:()=>import('@/views/student/studentinternInfo.vue'),name:'studentinternInfo',desc:'学生实习详情',meta:{isTab:true}},
        {path:'/student/studentjobApply',component:()=>import('@/views/student/studentjobApply.vue'),name:'studentjobApply',desc:'',meta:{isTab:true}},
        {path:'/student/studentMain',component:()=>import('@/views/student/studentMain.vue'),name:'studentMain',desc:'学生端主页',meta:{isTab:true}},
        {path:'/student/studentrecruitInfo',component:()=>import('@/views/student/studentrecruitInfo.vue'),name:'studentrecruitInfo',desc:'',meta:{isTab:true}},
      ],
      beforeEnter (to,from,next){
        let token = Vue.cookie.get('token');
        if(!token){
          next({name:'login',query:{redirect:to.fullPath}});
          let allowBack = true;
          if(to.meta.allowBack!==undefined){
            allowBack = to.meta.allowBack;
          }
          if(!allowBack){
            history.pushState(null,null,location.href);
          }
        }else{
          next();
        }
      }
    },
    {path:'*',redirect:{name:'404'}}
  ]
});
